package org.jamin.lending.domain.entity;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;

@Entity(name = "p2p_borrow_info")
public class BorrowInfo extends BasicEntity{

    @Column(name = "name")
    private String name;

    @Column(name = "total_money")
    private BigDecimal totalMoney;

    @ManyToOne
    @JoinColumn(name = "user_id")
    private UserInfo borrower;

    private Status status;

    /**
     * 周期
     */
    @Column(name = "periodico")
    private Integer periodico;

    @Column(name = "periodic_unit")
    private Integer periodicUnit;

    private Type type;

    /**
     * 年化收益率
     */
    @Column(name = "annualize_return")
    private BigDecimal annualizedReturn;

    @Column(name = "min_tender_money")
    private BigDecimal minTenderMoney;

    @Column(name = "max_tender_money")
    private BigDecimal maxTenderMoney;

    /**
     * 是否新手标
     */
    @Column(name = "novice")
    private boolean novice;

    @Column
    private boolean autoLoan;

    @Column
    private boolean autoTender;

    @Column(name = "create_time")
    private Timestamp createTime;

    @ManyToOne
    @JoinColumn(name = "preliminary_user")
    private Auser preliminaryUser;

    @Column(name = "preliminary_time")
    private Timestamp preliminaryTime;

    @Column(name = "release_time")
    private Timestamp releaseTime;

    @Column(name = "create_description")
    private String createDescription;

    @Column(name = "preliminary_description")
    private String preliminaryDescription;

    @OneToOne
    @PrimaryKeyJoinColumn(name = "borrow_id")
    private BorrowDescription borrowDescription;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public UserInfo getBorrower() {
        return borrower;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public void setBorrower(UserInfo borrower) {
        this.borrower = borrower;
    }

    public BigDecimal getTotalMoney() {
        return totalMoney;
    }

    public void setTotalMoney(BigDecimal totalMoney) {
        this.totalMoney = totalMoney;
    }

    public Integer getPeriodico() {
        return periodico;
    }

    public void setPeriodico(Integer periodico) {
        this.periodico = periodico;
    }

    public Integer getPeriodicUnit() {
        return periodicUnit;
    }

    public void setPeriodicUnit(Integer periodicUnit) {
        this.periodicUnit = periodicUnit;
    }

    public BigDecimal getAnnualizedReturn() {
        return annualizedReturn;
    }

    public void setAnnualizedReturn(BigDecimal annualizedReturn) {
        this.annualizedReturn = annualizedReturn;
    }

    public BigDecimal getMinTenderMoney() {
        return minTenderMoney;
    }

    public void setMinTenderMoney(BigDecimal minTenderMoney) {
        this.minTenderMoney = minTenderMoney;
    }

    public BigDecimal getMaxTenderMoney() {
        return maxTenderMoney;
    }

    public void setMaxTenderMoney(BigDecimal maxTenderMoney) {
        this.maxTenderMoney = maxTenderMoney;
    }

    public boolean isNovice() {
        return novice;
    }

    public void setNovice(boolean novice) {
        this.novice = novice;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Timestamp getPreliminaryTime() {
        return preliminaryTime;
    }

    public void setPreliminaryTime(Timestamp preliminaryTime) {
        this.preliminaryTime = preliminaryTime;
    }

    public Timestamp getReleaseTime() {
        return releaseTime;
    }

    public void setReleaseTime(Timestamp releaseTime) {
        this.releaseTime = releaseTime;
    }

    public boolean isAutoLoan() {
        return autoLoan;
    }

    public void setAutoLoan(boolean autoLoan) {
        this.autoLoan = autoLoan;
    }

    public boolean isAutoTender() {
        return autoTender;
    }

    public void setAutoTender(boolean autoTender) {
        this.autoTender = autoTender;
    }

    public Auser getPreliminaryUser() {
        return preliminaryUser;
    }

    public void setPreliminaryUser(Auser preliminaryUser) {
        this.preliminaryUser = preliminaryUser;
    }

    public BorrowDescription getBorrowDescription() {
        return borrowDescription;
    }

    public void setBorrowDescription(BorrowDescription borrowDescription) {
        this.borrowDescription = borrowDescription;
    }

    public String getCreateDescription() {
        return createDescription;
    }

    public void setCreateDescription(String createDescription) {
        this.createDescription = createDescription;
    }

    public String getPreliminaryDescription() {
        return preliminaryDescription;
    }

    public void setPreliminaryDescription(String preliminaryDescription) {
        this.preliminaryDescription = preliminaryDescription;
    }

    /**
     *
     */
    public enum Status{
        PRELIMINARY, PUBLISHER, REVIEW,REFUSE
    }

    public enum Type{
        MORTGAGE,CREDIT
    }
}
